package run.liuli.tran.user.conf;

import org.quartz.*;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import run.liuli.tran.user.quartz.CouponJob;

@Configuration
public class QuartzConfig {

    @Bean
    public JobDetail couponJobDetail(){
        return JobBuilder.newJob(CouponJob.class).withIdentity("coupon").storeDurably().build();
    }

    @Bean
    public Trigger couponJobTrigger(){
        return TriggerBuilder.newTrigger()
                .forJob(couponJobDetail())
                .withSchedule(CronScheduleBuilder.cronSchedule("0,15,30,45 * * * * ? "))
                .withIdentity("couponTrigger")
                .build();
    }

}
